package com.example.customer.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicExchangeConfig {

    @Bean("topicMessage")
    public Queue MessageQueue(){
        return QueueBuilder.durable("topic.message").maxLength(10).ttl(60000).build();
    }

    @Bean("topicMessage22")
    public Queue MessageQueue22(){
        return new Queue("topic.message22");
    }

    @Bean("topicExchange")
    public TopicExchange topicExchange(){
        return new TopicExchange("topicExchange");
    }

    @Bean
    Binding bindingTopicExchangeMessage(@Qualifier("topicMessage") Queue messageQueue, TopicExchange topicExchange){
        return BindingBuilder.bind(messageQueue).to(topicExchange).with("topic.message");
    }

    @Bean
    Binding bindingTopicExchangeMessage2(@Qualifier("topicMessage22")Queue messageQueue22,TopicExchange topicExchange){
        return BindingBuilder.bind(messageQueue22).to(topicExchange).with("topic.#");
    }
}
